Read and write the files in the SD card as follows: 1 call Environment's Getexternalstoragestate () method to determine if the SD card is plugged into the phone and the application has the ability to read and write the SD cardIf the phone is already plugged into an SD card and has the ability to read and write the SD card, the following statement will return TrueEnvironment.getexternalstoragestate (). Equals (envronment.media_mounted)2) Call Environment's getExternalStorageDirectory () method to
Django file storage (2) custom storage system, django file storage
To write a storage system by yourself, follow these steps:
1. Write a file inherited from django. core. files.
getfilesdir,getexternalfilesdir,getexternalstoragedirectory, Getexternalstoragepublicdirectory and other Android file operation methods, I will print out the results of these methods to see exactly what the path is, execute the following code in the activity:
123456
Log.i("codecraeer","getFilesDir = "+ getFilesDir());Log.i("codecraeer","getExternalFilesDir = "+ getExternalFilesDir("exter_test").getAbsolutePath());Log.i("codecraeer","
()); LOG.I ("Codecraeer", "getexternalstoragepublicdirectory =" + Environment.getexternalstoragepublicdirectory (" Pub_test "));See the following results in log:From the log we can see that the external storage root is/storage/emulated/0 on my phone (Nexus 3), and oddly enough on some phones the same code is the follo
FIS = openfileinput ("Test.txt"); the //1. Definition byte[] - byte[] B =New byte[1024]; - inti = 0;//length of data read theString str1 = ""; the //2. Cyclic reading the while((i = Fis.read (b)) >0) the { -String str =NewString (b,0, i); theSTR1 + =str; the } the fis.close ();9
In previous studies, when we needed to store the data in the program, we generally used lists, tuples, and so on, or used the files mentioned in the previous blog, this blog introduces a method of permanent data storage--pickle module
Because it is relatively simple, it is directly on the code
The main use is the dump and load functions in pickle.
Import picklemy_list=[123,456, "Little Turtle", [' another list ']] #以二进制的方式写入pickle_file =open (' e:\
Talk about how to create a file share in an Azure storage account and mount it on an azure VM today. (By the way, the Chinese Azure official documents can be translated, literal translation of global Azure, the technical documentation of the calibration is not good)We'll start by creating a test VM on Azure, for reference: http://gshao.blog.51cto.com/3512873/13448461. Create a
redis/Distributed File storage System/Database storage session, solve the problem of session inconsistency in load Balancing cluster, redissession
First, the similarities and differences between the session and the cookie
Sessions and cookies are not just a store on the server side, a general
Although the session is stored on the server side, but also needs to
current application as the prefix to name the SharedPreferences file.
After obtaining the SharedPreferences object, you can start to store data in the SharedPreferences file in three steps:
Call the edit () method of the SharedPreferences object to obtain a SharedPreferences. Editor object.
Add data to the SharedPreferences. Editor object. For example, to add a boolean data, use the putBoolean (
Catch(Exception e) the { the e.printstacktrace (); theToast.maketext (mainactivity. This, "Error storing file", Toast.length_short). Show (); + } - } the ElseBayi { theToast.maketext (mainactivity. This, "SD card is not mounted", Toast.length_short). Show (); the } - } - the Public voidBt7_onclick (View v) the { the //1. Determine if the SD card is mounted the
in the local directory of each server, and corresponding configurations are available in 'php. ini '.
Server Configuration:
Session. save_handler = files (the default value is file, which defines the session storage method on the server. file means to save the sesion to a temporary file. If we want to save it in anot
(); //2). Form the full path String FilePath = Filespath + "/" + FileName; 3). Create FileInputStream FileInputStream fis = new FileInputStream (filePath); 4. Reads the data into string Bytearrayoutputstream BAOs = new Bytearrayoutputstream (); byte[] buffer = new byte[1024]; int len =-1; while ((Len=fis.read (buffer))!=-1) { Baos.write (buffer, 0, Len); } String content = baos.tostring (); //5. Display Et_of_content.settext (content); } e
Android-based file data storage and android-based Data Storage1. Introduction to file storage data
Activity provides the openFileOutput () method to output data to a file. The specific implementation process is the same as saving data to a
parameter and automatically uses the current application's package name as a prefix to name the sharedpreferences file
Once you get the Sharedpreferences object, you can begin to store data in the Sharedpreferences file, with three main steps:
Call the edit () method of the Sharedpreferences object to get a Sharedpreferences.editor object
Add data to the Sharedpreferences.edit
Android-file storage-text Storage
[Return directory]
If you want to perform file input or output operations, you need to perform stream operations.
Activity Support for file operations
Public FileInputStream openFileInput (String name)Set the
[Return to Table of contents]If you want to do a file input or output operation, you need to do the flowActivity's support for file operationsPublic FileInputStream openfileinput (String name) sets the file input stream to openPublic FileOutputStream openfileoutput (String name,int mode) sets the file output stream to
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.